package com.neuedu.dao.impl;

import com.neuedu.dao.RenYuanDao;
import com.neuedu.model.FangChan;
import com.neuedu.model.RenYuan;
import com.neuedu.util.DBUtil;

import java.util.List;

public class RenYuanDaoImpl implements RenYuanDao {
    @Override
    public List<RenYuan> selectPageList(Integer limitParams1, Integer limitParams2, String startTime, String endTime, String name) {
        List<RenYuan> list = DBUtil.findByWhere(RenYuan.class,
                "chuangjianshijian >= ? and chuangjianshijian <= ? and mingcheng like ? limit ?,?",
                startTime, endTime, "%" + name + "%", limitParams1, limitParams2);
        return list;
    }

    @Override
    public int selectCount(String startTime, String endTime, String name) {
        return DBUtil.findByWhere(RenYuan.class,
                "chuangjianshijian >= ? and chuangjianshijian <= ? and mingcheng like ?",
                startTime, endTime, "%" + name + "%").size();

    }

    @Override
    public int add(RenYuan renYuan) {
        renYuan.setId(null);

        return DBUtil.insert(renYuan);
    }

    @Override
    public RenYuan selectRenYuanOne(Integer id) {
        return DBUtil.findOneByWhere(RenYuan.class,"id=?",id);
    }

    @Override
    public int updateRenYuan(RenYuan renYuan) {
        return DBUtil.updateSelective(renYuan,"id=?",renYuan.getId());
    }
}
